﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WenSkin.Controls;

namespace WenFrame.UserControls
{
    public partial class WenUserControlDataGridTem : WenUserControl
    {
        private readonly StartForm startForm;
        private WenSkin.SQL.SqlConnect SqlConnect = new WenSkin.SQL.SqlConnect();
        public WenUserControlDataGridTem(StartForm startForm)
        {
            this.startForm = startForm;
            InitializeComponent();
            wenDataGridView1.AutoGenerateColumns = false;
            ReDataAsync();
            new WenUserControlPower(this).SetPower();
        }

        #region 公有属性 
        [Category("Wen"), Description("数据库内容"), DefaultValue("")]
        [Editor(typeof(WenSkin.Design.Editor.TextEditFormUITypeEditor), typeof(UITypeEditor))]
        public string SqlString { get; set; }
        #endregion

        private async void ReDataAsync(string soutext = "")
        {
            wenDataGridView1.DataSource = await SqlConnect.SqlDataTableAsync(string.Format(SqlString, soutext));
        }

        private void ToolStripButton1_Click(object sender, EventArgs e)
        {
            ReDataAsync();
        }
        private void ToolStripButton2_Click(object sender, EventArgs e)
        {
            ReDataAsync(soutextbox.Text);
        }

        private void WenDataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
                return;        
        }
    }
}
